package org.suk.dp.simpleFactory;

/**
 * Description: 操作简单工厂类<br/>
 * @version V1.0  2017/6/20 11:58  by 石冬冬(dongdong.shi@ucarinc.com) - Heil Hitler
 */
public class OperationFactory {
    /**
     * 操作类型枚举
     */
    enum OperationEnum{
        ADD,SUB,MUL,DIV
    }

    /**
     * 根据枚举获取对应的操作类
     * @param operationEnum
     * @return
     */
    public static Operation createOperation(OperationEnum operationEnum){
        Operation operation = null;
        switch (operationEnum){
            case ADD:
                operation = new OperationAdd();
                break;
            case SUB:
                operation = new OperationSub();
                break;
            case MUL:
                operation = new OperationMul();
                break;
            case DIV:
                operation = new OperationDiv();
                break;
        }
        return operation;
    }
}
